package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Porprojectauthor;
import com.hbnu.system.service.PorprojectauthorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/porprojectauthor")
@Api(tags = "纵向项目作者模块")
public class PorprojectauthorController {

    @Autowired
    private PorprojectauthorService porprojectauthorService;
    @ApiOperation("新增纵向项目作者")
    @PostMapping("/addauthor")
    public Rest<String> addAuthor(@RequestBody Porprojectauthor porprojectauthor){
        boolean ba = porprojectauthorService.addporprojectAuthor(porprojectauthor);
        return ba ? Rest.success() : Rest.failed();
    }

    @ApiOperation("删除作者信息")
    @GetMapping ("/deleteauthor")
    public Rest<String> delete(String id){
        boolean ba1 = porprojectauthorService.deleteporprojectAuthor(id);
        return ba1?Rest.success():Rest.failed();
    }
    @ApiOperation("修改作者信息")
    @PostMapping("/updateauthor")
    public Rest<String> updateAuthor(@RequestBody Porprojectauthor porprojectauthor){
        boolean ba2=porprojectauthorService.updateporprojectAuthor(porprojectauthor);
        return ba2?Rest.success():Rest.failed();
    }
    @ApiOperation("搜索作者信息")
    @GetMapping("/selectauthor")
    public Rest<List<Porprojectauthor>> selectAuthor(String id){
        List<Porprojectauthor> pa=porprojectauthorService.porprojectauthor(id);
        return Rest.success(pa,pa.size());
    }
}

